/*
 * CDollTableModel.java
 *
 * Copyright (c) 2009 Giles Millward (Manigra). All rights reserved.
 *
 * This file is part of JRogueDPS.
 *
 * JRogueDPS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JRogueDPS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JRogueDPS.  If not, see <http://www.gnu.org/licenses/>.
 */
package paperdoll;

import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Mani
 */
public class CDollTableModel extends AbstractTableModel {

    String[] columnNames = {"Slot", "Equipped"};
    CPaperDoll m_paperDoll;

    public void setDataLink(CPaperDoll p_paperDoll)
    {
        m_paperDoll = p_paperDoll;
        this.fireTableStructureChanged();
    }

    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        if (m_paperDoll == null)
        {
            return 0;
        }
        
        return m_paperDoll.m_dollSlotRenderMap.size();
    }

    @Override
    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return m_paperDoll;
    }

    /*
     * JTable uses this method to determine the default renderer/
     * editor for each cell.  If we didn't implement this method,
     * then the last column would contain text ("true"/"false"),
     * rather than a check box.
     */
    @Override
    public Class getColumnClass(int c) {
        return CPaperDoll.class;
    }

    /*
     * Don't need to implement this method unless your table's
     * editable.
     */
    @Override
    public boolean isCellEditable(int row, int col) {
        //Note that the data/cell address is constant,
        //no matter where the cell appears onscreen.
        return false;
    }

/*
     * Don't need to implement this method unless your table's
     * data can change.
     */
/*    @Override
    public void setValueAt(Object value, int row, int col) {
        m_arrayList.get(col).set(row, value);
        fireTableCellUpdated(row, col);
    }
*/
}
